package org.sction.server.ftp;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.ftpserver.ConnectionConfig;

public class FtpConnectionConfig implements ConnectionConfig {
	private String configPath = "";
	Properties p = new Properties();

	public String getConfigPath() {
		return configPath;
	}

	public void setConfigPath(String configPath) {
		this.configPath = configPath;
		File file = new File(configPath);
		try {
			p.load(new FileInputStream(file));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public FtpConnectionConfig(String filePath) {
		configPath = filePath;
		File file = new File(configPath);
		try {
			p.load(new FileInputStream(file));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public int getLoginFailureDelay() {
		return Integer.parseInt(p.getProperty("loginFailureDelay"));
	}

	public int getMaxAnonymousLogins() {
		return Integer.parseInt(p.getProperty("maxAnonymousLogins"));
	}

	public int getMaxLoginFailures() {
		return Integer.parseInt(p.getProperty("maxLoginFailures"));
	}

	public int getMaxLogins() {
		return Integer.parseInt(p.getProperty("maxLogins"));
	}

	public int getMaxThreads() {
		return Integer.parseInt(p.getProperty("maxThreads"));
	}

	public boolean isAnonymousLoginEnabled() {
		return Boolean.parseBoolean(p.getProperty("anonymousLoginEnabled"));
	}

}
